package cn.dhn_app.horseman_app.server.feign.Impl;

import cn.dhn_app.horseman_app.entity.token;
import cn.dhn_app.horseman_app.entity.tokenExample;
import cn.dhn_app.horseman_app.mapper.tokenMapper;
import cn.dhn_app.horseman_app.server.feign.FeignInterface;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * @Author lyy
 * @Description TODO
 * @PACKAGE_NAME: cn.dhn_app.server.feign.Impl
 * @ClassName FeignTokenInterface
 * @Date 2020/8/27 17:20
 * @DAY_NAME_FULL: 星期四
 * @Version 1.0
 **/
@Service
public class FeignTokenInterface implements FeignInterface {

    @Resource
    private tokenMapper tokenMapper;

    @Override
    public token getToken(String token) {
        tokenExample example = new tokenExample();
        tokenExample.Criteria criteria = example.createCriteria();
        criteria.andTokenEqualTo(token);
        List<token> tokenList = tokenMapper.selectByExample(example);
        if(tokenList.isEmpty() && tokenList.size()==0){
            return null;
        }else {
            return tokenMapper.selectByPrimaryKey(tokenList.get(0).getId());
        }
    }
}
